﻿@{
    Layout = null;
}
@model System.Collections.IEnumerable
<!DOCTYPE html>

<html>
@Html.Partial("LoadPanelPartial")
<head>
  @if (false)
    {
        <script src="../../../../Scripts/jquery-vsdoc.js" type="text/javascript"></script>
        <script src="../../../../Scripts/ASPxScriptIntelliSense.js" type="text/javascript"></script>
    }
    <link href="@Url.Content("~/Content/Site.css", true)" rel="stylesheet" type="text/css" />

    <script src="@Url.Content("~/Scripts/jquery.min.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/FloatDiv.js", true)" type="text/javascript"></script>
    <script src="@Url.Content("~/Common/GetRootPath.ashx", true)" type="text/javascript"></script>
    
    @Html.DevExpress().GetStyleSheets(

                new StyleSheet { ExtensionType = ExtensionType.GridView, Theme = DevExpressHelper.Theme }

)
    @Html.DevExpress().GetScripts(
                    new Script { ExtensionType = ExtensionType.ListBox }
    
    )
        @Html.DevExpress().GetStyleSheets(

        new StyleSheet { ExtensionType = ExtensionType.ListBox, Theme = DevExpressHelper.Theme }
)

    <script type="text/javascript">
        var isRefreshAll = false;//是否全部刷新，还是刷新当前页
        $(function () {
            $("#toolMenu").smartFloat();
        });

        function OnBeginCallback(s, e) {
            e.customArgs["command"] = e.command;
            e.customArgs["pageIndex"] = s.pageIndex;
            e.customArgs["pageCount"] = s.pageCount;
            e.customArgs["pageRowSize"] = s.pageRowSize;
            e.customArgs["pageRowCount"] = s.pageRowCount;
            e.customArgs["deptNo"] = $('#hidDeptNo').val();
            e.customArgs["QueryName"] = $('#hidQueryName').val();
            e.customArgs["isRefreshAll"] = isRefreshAll;
        }

        function MenuTop_emClick(source, e) {
            switch (e.item.name) {
                case "btnAdd":
                    {
                        //增加
                        window.location.href = rootPath + "/Admin/Empl/EmpContent";
                        break;
                    }
                case "btnSeqSameLevel":
                    {
                        //同部门人员排序
                        seqSameLevel();
                        break;
                    }
                case "btnDelete":
                    {
                        //删除
                        empManyDel();
                        break;
                    }
            }
        }
        /*同部门人员排序*/
        function seqSameLevel() {
            var deptNo = $('#hidDeptNo').val();
            var url = rootPath + "/Admin/Empl/EmplSeq?deptNo=" + deptNo;
            var returnValue = window.showModalDialog(url, 'empltopseq', 'dialogWidth:700px;dialogHeight:500px');
            if (typeof (returnValue) != "undefined") {
                if (returnValue == "SUCCESS") {
                    //var keyFocuse = deptNo;
                    //parent.refreshLevelNode(keyFocuse);
                    refreshGrid(true);
                }

            }

        }
        function refreshGrid(refresh) {
            isRefreshAll = refresh;
            var clientgvDocumentObj = ASPxClientGridView.Cast("gvEditing");
            clientgvDocumentObj.Refresh();
        }
        //批量删除
        function empManyDel() {
            var empNos = gvEditing.GetSelectedKeysOnPage();
            if (empNos.length == 0) {
                alert("请选择要删除的数据");
            } else {
                if (confirm("确定删除")) {
                    var empNoArray = "";
                    for (var i = 0; i < empNos.length; i++) {
                        empNoArray += empNos[i] + "%!^";
                    }

                    $.ajax({
                        type: 'POST',
                        url: rootPath + '/Admin/Empl/DeleteManyEmp',
                        data: { empNos: empNoArray },
                        success: function (result) {
                            if (result == "ok") {
                                alert("删除成功!");
                                gvEditing.Refresh();
                            } else if (result == "error") {
                                alert("删除失败!");
                            } else {
                                alert("删除参数错误!");
                            }
                        }
                    });

                }
            }
        }


        function search() {
            window.location.href = rootPath + "/Admin/Empl/EmplList?xm=" + FUserName.GetText();
        }


        //编辑
        function emplEdit(empNo) {
            var clientgvDocumentObj = ASPxClientGridView.Cast("gvEditing");
            var pageIndex = clientgvDocumentObj.GetPageIndex() + 1;
            var treeDeptNo = $("#hidDeptNo").val();
            window.location.href = rootPath + "/Admin/Empl/EmpContent?empNo=" + empNo + "&treeDeptNo=" + treeDeptNo + "&pageIndex=" + pageIndex;
        }

        //删除
        function emplDel(empNo) {
            if (confirm("确定删除")) {
                $.ajax({
                    type: 'POST',
                    url: rootPath + '/Admin/Empl/DelEmp',
                    data: { empNo: empNo },
                    success: function (result) {
                        if (result == "ok") {
                            alert("删除成功!");
                            gvEditing.Refresh();
                        } else if (result == "error") {
                            alert("删除失败!");
                        } else {
                            alert("删除参数错误!");
                        }
                    }
                });
            }
        }

    </script>

</head>
<body>
 <div class="floatToolMenu" id="toolMenu">
        @Html.DevExpress().Menu(settings =>
       {
           settings.Name = "toolBarMenu";
           settings.ItemAutoWidth = false;
           settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
           settings.Styles.Style.Border.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(0);
           settings.Styles.Style.BorderTop.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(1);

           settings.Items.Add(item =>
           {
               item.Name = "btnAdd";
               item.Text = "增加";
               item.ClientEnabled = true;
               item.Image.Url = Url.Content("~/Content/ControlImages/edit_add.png");

           });
           settings.Items.Add(item =>
           {
               item.Name = "btnSeqSameLevel";
               item.Text = "同部门人员排序";
               item.ClientEnabled = true;
               item.Visible = ViewData["deptNo"] != null ? true : false;
               item.Image.Url = Url.Content("~/Content/ControlImages/move.png");

           });
           settings.Items.Add(item =>
           {
               item.Name = "btnDelete";
               item.Text = "删除";
               item.ItemStyle.ForeColor = System.Drawing.Color.Red;
               item.ClientEnabled = true;
               item.Image.Url = Url.Content("~/Content/ControlImages/cancel.png");

           });
           settings.ClientSideEvents.ItemClick = "function(source,e){MenuTop_emClick(source,e)}";
           settings.ItemLinkMode = ItemLinkMode.ContentBounds;
       }).GetHtml()
    </div>
   <table width="100%" class="tableForm">
    <tr>
    <td align="right">
    姓名:
    </td>
    <td align="left" style=" width:400px">
    
   @Html.DevExpress().TextBox(settings =>
          {
              settings.Name = "FUserName";
              settings.Width = System.Web.UI.WebControls.Unit.Percentage(96);
              settings.Text = ViewData["QueryName"].ToString();     
          }).GetHtml()

    </td>
    <td align="left">
      @Html.DevExpress().Button(settings =>
            {
                settings.Name = "btnSearch";
                settings.Text = "查询";
                settings.ControlStyle.CssClass = "button";
                settings.Images.Image.Url = Url.Content("~/Content/ControlImages/search.png");
                settings.ClientSideEvents.Click = "search";
            }).GetHtml()
    </td>
    </tr>
    </table>
    @Html.Partial("EmpListPartial", Model)
    @Html.Hidden("hidDeptNo", ViewData["deptNo"])
    @Html.Hidden("hidQueryName", ViewData["QueryName"])
     <script>
         lp.Hide();
    </script>
</body>
</html>
